//
//  OrderMessageTableViewCell.m
//  rrqs
//
//  Created by 徐浩 on 2019/5/6.
//

#import "OrderMessageTableViewCell.h"

@interface OrderMessageTableViewCell()

@property(nonatomic,strong) UILabel* orderNumLabel;
@property(nonatomic,strong) UILabel* OrderTimeLabel;
@property(nonatomic,strong) UILabel* requireLabel;
@property(nonatomic,strong) UILabel* typeLabel;

@end

@implementation OrderMessageTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self =  [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        
        UILabel *orderNum = [[UILabel alloc]init];
        [self.contentView addSubview:orderNum];
        [orderNum mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kSizeRatio(46));
            make.top.equalTo(self.contentView.mas_top).offset(20);
        }];
        orderNum.textColor = [UIColor blackColor];
        orderNum.text = @"订单号码";
        orderNum.textAlignment = 0;
        orderNum.font = kFontNameSize(14);
        
        UILabel *copyLabel = [[UILabel alloc]init];
        [self.contentView addSubview:copyLabel];
        [copyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView.mas_right).offset(kSizeRatio(-46));
//            make.top.equalTo(self.contentView.mas_top).offset(18);
            make.centerY.equalTo(orderNum.mas_centerY);
            make.size.mas_equalTo(CGSizeMake(kSizeRatio(68), 18));
        }];
        copyLabel.textColor = COLORRGB(0x999999);
        copyLabel.text = @"复制";
        copyLabel.textAlignment = 1;
        copyLabel.font = kFontNameSize(11);
        copyLabel.layer.cornerRadius = 3;
        copyLabel.layer.masksToBounds = YES;
        copyLabel.layer.borderColor = COLORRGB(0x999999).CGColor;
        copyLabel.layer.borderWidth = 1;
        [copyLabel setUserInteractionEnabled:YES];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAciton)];
        [copyLabel addGestureRecognizer:tap];
        
        self.orderNumLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.orderNumLabel];
        [self.orderNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(copyLabel.mas_left).offset(kSizeRatio(-10));
            make.top.equalTo(self.contentView.mas_top).offset(20);
        }];
        self.orderNumLabel.textColor = [UIColor blackColor];
        self.orderNumLabel.text = @"1234567890";
        self.orderNumLabel.textAlignment = 2;
        self.orderNumLabel.font = kFontNameSize(14);
        
        UILabel *orderTime = [[UILabel alloc]init];
        [self.contentView addSubview:orderTime];
        [orderTime mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kSizeRatio(46));
            make.top.equalTo(self.orderNumLabel.mas_bottom).offset(20);
        }];
        orderTime.textColor = [UIColor blackColor];
        orderTime.text = @"下单时间";
        orderTime.textAlignment = 0;
        orderTime.font = kFontNameSize(14);
        
        
        self.OrderTimeLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.OrderTimeLabel];
        [self.OrderTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView.mas_right).offset(kSizeRatio(-46));
            make.top.equalTo(self.orderNumLabel.mas_bottom).offset(20);
        }];
        self.OrderTimeLabel.textColor = [UIColor blackColor];
        self.OrderTimeLabel.text = @"2019-05-06 15:00";
        self.OrderTimeLabel.textAlignment = 2;
        self.OrderTimeLabel.font = kFontNameSize(14);
        
        UILabel *require = [[UILabel alloc]init];
        [self.contentView addSubview:require];
        [require mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kSizeRatio(46));
            make.top.equalTo(self.OrderTimeLabel.mas_bottom).offset(20);
        }];
        require.textColor = [UIColor blackColor];
        require.text = @"要求";
        require.textAlignment = 0;
        require.font = kFontNameSize(14);
        
        
        self.requireLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.requireLabel];
        [self.requireLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView.mas_right).offset(kSizeRatio(-46));
            make.top.equalTo(self.OrderTimeLabel.mas_bottom).offset(20);
        }];
        self.requireLabel.textColor = [UIColor blackColor];
        self.requireLabel.text = @"14点之前送达";
        self.requireLabel.textAlignment = 2;
        self.requireLabel.font = kFontNameSize(14);
        
        UILabel *type = [[UILabel alloc]init];
        [self.contentView addSubview:type];
        [type mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kSizeRatio(46));
            make.top.equalTo(self.requireLabel.mas_bottom).offset(20);
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-32);
        }];
        type.textColor = [UIColor blackColor];
        type.text = @"支付方式";
        type.textAlignment = 0;
        type.font = kFontNameSize(14);
        
        
        self.typeLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.typeLabel];
        [self.typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView.mas_right).offset(kSizeRatio(-46));
            make.top.equalTo(self.requireLabel.mas_bottom).offset(20);
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-32);
        }];
        self.typeLabel.textColor = [UIColor blackColor];
        self.typeLabel.text = @"微信";
        self.typeLabel.textAlignment = 2;
        self.typeLabel.font = kFontNameSize(14);
        
    }
    return self;
}

-(void)tapAciton
{
    if (self.OrderMessageTableViewCellDelegate && [self.OrderMessageTableViewCellDelegate respondsToSelector:@selector(clickCopy)]) {
        [self.OrderMessageTableViewCellDelegate clickCopy];
    }
}

-(void) reloadUIWithDic:(NSDictionary *)dic
{
    self.orderNumLabel.text =   [Config isBlankString:[NSString stringWithFormat:@"%@",dic[@"order_number"]]] ? @"" : [NSString stringWithFormat:@"%@",dic[@"order_number"]];
    self.OrderTimeLabel.text =   [Config isBlankString:[NSString stringWithFormat:@"%@",dic[@"reas_time"]]] ? @"" : [NSString stringWithFormat:@"%@",dic[@"reas_time"]];
    self.requireLabel.text =   [Config isBlankString:[NSString stringWithFormat:@"%@",dic[@"yaoqiu"]]] ? @"" : [NSString stringWithFormat:@"%@",dic[@"yaoqiu"]];
    self.typeLabel.text =   [Config isBlankString:[NSString stringWithFormat:@"%@",dic[@"add_time"]]] ? @"" : [NSString stringWithFormat:@"%@",dic[@"add_time"]];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
